﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace EmployeeCheckIn
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindingGrid();
            if (Session["User"] != null)
            {
                lbWelUser.Text = Session["User"].ToString();
            }
        }
        private void BindingGrid()
        {
            DataTable dt = GetData();
            gvEmpDetail.DataSource = dt;
            gvEmpDetail.DataBind();

        }
        private DataTable GetData()
        {
            string sqltext = "select * from employee ";
            SqlConnection sqlconn = new SqlConnection("Server=NUEK-PC\\SA;Database=DB_CHECK_EMPLOYEE;User Id=sa;Password=1234qwer;");
            SqlDataAdapter da = new SqlDataAdapter(sqltext, sqlconn);
            DataSet ds = new DataSet();
            da.Fill(ds);

            return ds.Tables[0];

        }

        protected void lkLogout_Click(object sender, EventArgs e)
        {
            Session["UserBack"] = lbWelUser.Text;
            Server.Transfer("Default.aspx"); 
            //Response.Redirect("Default.aspx"); 
        }

        protected void gvEmpDetail_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

       
    }
}